<?php

Yii::import('application.models._base.BaseCustomerOrderShippingInfo');


class CustomerOrderShippingInfo extends BaseCustomerOrderShippingInfo
{	public $shipping_ffl_dealer_name;
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
	
	public function getFullAddress(){
		$country = Country::model()->findByPk($this->shipping_country)->name;
		$state = State::model()->findByPk($this->shipping_state)->name;
		return $this->shipping_address1.' '.$this->shipping_address2.' '.$this->shipping_city.' '.$country.' '.$state.' '.$this->shipping_zip;
	}
	
	public function rules() {
		return array(
				array('shipping_first_name, shipping_last_name, shipping_address1, shipping_city, shipping_phone,shipping_zip', 'required'),
				array('shipping_state, shipping_country, created, enable', 'numerical', 'integerOnly'=>true),
				// array('shipping_zip,shipping_phone', 'numerical', 'integerOnly'=>true),
				// array('shipping_zip', 'length', 'max'=>6),
// 				array('customer_id', 'length', 'max'=>10),
// 				array('shipping_first_name, shipping_last_name, shipping_barangay, shipping_city, shipping_province, shipping_region', 'length', 'max'=>100),
				array('shipping_address1, shipping_address2', 'length', 'max'=>200),
				array('shipping_zip, shipping_phone', 'length', 'max'=>45),
				array('shipping_phone','match','pattern'=>'/^[0-9]{10}$/','message'=>'Phone wrong format'),
				array('shipping_zip','match','pattern'=>'/^[0-9]{5}$/','message'=>'Zip wrong format'),
// 				array('id, customer_id, shipping_first_name, shipping_last_name, shipping_address1, shipping_address2, shipping_barangay, shipping_city, shipping_state, shipping_province, shipping_region, shipping_country, shipping_zip, shipping_phone, created, enable', 'safe'),
				array('id, customer_id, shipping_ffl_dealer_name,shipping_first_name, shipping_last_name, shipping_address1, shipping_address2, shipping_barangay, shipping_city, shipping_state, shipping_province, shipping_region, shipping_country, shipping_zip, shipping_phone, created, enable', 'safe'),
		);
	}
		
}